group_by(genotype) %>%
add_column(lowMIfreq = 0) # add empty column to fill in later with frequencies
# p-value is set as variable lowMI
lowMI = 0.05
numRowsTable = NROW(MIfreq)
for (i in 1:numRowsTable){
df <- MI_data_AM_day1_only %>%
filter(session == as.character(MIfreq[i,1]))
freq = NROW(filter(df, MI_p_values<lowMI)) / NROW(df)
MIfreq[i,6]=freq
}
# make table of average values of pMI by animal_ID under each condition
pMItable <- aggregate(lowMIfreq ~ genotype:animal_ID:drug, data = MIfreq, mean,
simplify = TRUE)
#################################################################
# test for interaction in mixed effects model
MI.model= lmer (lowMIfreq ~ drug + (1|animal_ID) + (1|expt_date), data=MIfreq, REML=FALSE)
anova(
MI.model,
type = c("III", "II", "I", "3", "2", "1"),
ddf = c("Satterthwaite", "Kenward-Roger", "lme4"))
# generate figs
MI.model= lmer(lowMIfreq ~ drug + (1|animal_ID) + (1|expt_date), data=MIfreq, REML=TRUE)
par(mfrow=c(1,3))
plot(residuals(MI.model),las=1, ylim=c(-2,2))
hist(residuals(MI.model),las=1)
qqnorm(residuals(MI.model),las=1)
qqline(residuals(MI.model), col = "red", lwd=2)
coef(MI.model)
summary(MI.model)
sjPlot::plot_model(MI.model, title = "MI ~ drug + (1|animal_ID) + (1|expt_date)")
sjPlot:: tab_model(MI.model, title = "MI ~  (1|animal_ID) + (1|expt_date)")
# Perform LMEM statistics on pMI and MI data (place cell proportions)
# specify directory to the data file (excel/csv)
# change to match your local machine
MI_and_pMI <- read_excel("D:/Meta_AnaOutput_Graphs/Zhu 2022 GAD paper (combined p-WTs)/MI_and_pMI.xlsx")
# get data and filter for only first session (day1/AM)
# filter out data where mobility is below a certain threshold
MIfreq <- MI_and_pMI
MI_data_AM_day1_only <- MIfreq %>%
filter(expt_time == "day1" | expt_time == "AM") %>%
filter(Mobility_Pass == 1) %>%
filter(drug != 'altered contexts') %>%
filter(genotype == 'a5-i-KO')
# filter out data that you don't need for place cell statistics
MIfreq <- MI_data_AM_day1_only %>%
nest_by(session,genotype,animal_ID,drug,expt_date,.keep=TRUE) %>%
dplyr::select(session,genotype,animal_ID,drug,expt_date)
# adjust the levels of data & set the baseline (saline) for comparison
MIfreq$drug <- factor(MIfreq$drug, levels = c("saline", "etomidate 2mg/kg", "etomidate 4mg/kg", "etomidate 6mg/kg", "etomidate 7mg/kg", "etomidate 8mg/kg"))
# avoid bugs
MIfreq <- MIfreq %>%
group_by(genotype) %>%
add_column(lowMIfreq = 0) # add empty column to fill in later with frequencies
# p-value is set as variable lowMI
lowMI = 0.05
numRowsTable = NROW(MIfreq)
for (i in 1:numRowsTable){
df <- MI_data_AM_day1_only %>%
filter(session == as.character(MIfreq[i,1]))
freq = NROW(filter(df, MI_p_values<lowMI)) / NROW(df)
MIfreq[i,6]=freq
}
# make table of average values of pMI by animal_ID under each condition
pMItable <- aggregate(lowMIfreq ~ genotype:animal_ID:drug, data = MIfreq, mean,
simplify = TRUE)
#################################################################
# test for interaction in mixed effects model
MI.model= lmer (lowMIfreq ~ drug + (1|animal_ID) + (1|expt_date), data=MIfreq, REML=FALSE)
anova(
MI.model,
type = c("III", "II", "I", "3", "2", "1"),
ddf = c("Satterthwaite", "Kenward-Roger", "lme4"))
# generate figs
MI.model= lmer(lowMIfreq ~ drug + (1|animal_ID) + (1|expt_date), data=MIfreq, REML=TRUE)
par(mfrow=c(1,3))
plot(residuals(MI.model),las=1, ylim=c(-2,2))
hist(residuals(MI.model),las=1)
qqnorm(residuals(MI.model),las=1)
qqline(residuals(MI.model), col = "red", lwd=2)
coef(MI.model)
summary(MI.model)
sjPlot::plot_model(MI.model, title = "MI ~ drug + (1|animal_ID) + (1|expt_date)")
sjPlot:: tab_model(MI.model, title = "MI ~  (1|animal_ID) + (1|expt_date)")
# Perform LMEM statistics on pMI and MI data (place cell proportions)
# specify directory to the data file (excel/csv)
# change to match your local machine
MI_and_pMI <- read_excel("D:/Meta_AnaOutput_Graphs/Zhu 2022 GAD paper (combined p-WTs)/MI_and_pMI.xlsx")
# get data and filter for only first session (day1/AM)
# filter out data where mobility is below a certain threshold
MIfreq <- MI_and_pMI
MI_data_AM_day1_only <- MIfreq %>%
filter(expt_time == "day1" | expt_time == "AM") %>%
filter(Mobility_Pass == 1) %>%
filter(drug != 'altered contexts') %>%
filter(genotype == 'a5-pyr-KO')
# filter out data that you don't need for place cell statistics
MIfreq <- MI_data_AM_day1_only %>%
nest_by(session,genotype,animal_ID,drug,expt_date,.keep=TRUE) %>%
dplyr::select(session,genotype,animal_ID,drug,expt_date)
# adjust the levels of data & set the baseline (saline) for comparison
MIfreq$drug <- factor(MIfreq$drug, levels = c("saline", "etomidate 2mg/kg", "etomidate 4mg/kg", "etomidate 6mg/kg", "etomidate 7mg/kg", "etomidate 8mg/kg"))
# avoid bugs
MIfreq <- MIfreq %>%
group_by(genotype) %>%
add_column(lowMIfreq = 0) # add empty column to fill in later with frequencies
# p-value is set as variable lowMI
lowMI = 0.05
numRowsTable = NROW(MIfreq)
for (i in 1:numRowsTable){
df <- MI_data_AM_day1_only %>%
filter(session == as.character(MIfreq[i,1]))
freq = NROW(filter(df, MI_p_values<lowMI)) / NROW(df)
MIfreq[i,6]=freq
}
# make table of average values of pMI by animal_ID under each condition
pMItable <- aggregate(lowMIfreq ~ genotype:animal_ID:drug, data = MIfreq, mean,
simplify = TRUE)
#################################################################
# test for interaction in mixed effects model
MI.model= lmer (lowMIfreq ~ drug + (1|animal_ID) + (1|expt_date), data=MIfreq, REML=FALSE)
anova(
MI.model,
type = c("III", "II", "I", "3", "2", "1"),
ddf = c("Satterthwaite", "Kenward-Roger", "lme4"))
# generate figs
MI.model= lmer(lowMIfreq ~ drug + (1|animal_ID) + (1|expt_date), data=MIfreq, REML=TRUE)
par(mfrow=c(1,3))
plot(residuals(MI.model),las=1, ylim=c(-2,2))
hist(residuals(MI.model),las=1)
qqnorm(residuals(MI.model),las=1)
qqline(residuals(MI.model), col = "red", lwd=2)
coef(MI.model)
summary(MI.model)
sjPlot::plot_model(MI.model, title = "MI ~ drug + (1|animal_ID) + (1|expt_date)")
sjPlot:: tab_model(MI.model, title = "MI ~  (1|animal_ID) + (1|expt_date)")
# linear mixed model statistics for PV correlations
# load data
PV_correlation <- read_excel("D:/Meta_AnaOutput_Graphs/Zhu 2022 GAD paper (combined p-WTs)/PV_correlation.xlsx")
# filter out data based on mobility of the animal
PV_values <- PV_correlation %>%
filter(session1_mobility_pass == 1 & session2_mobility_pass == 1) %>%
filter(drug != 'altered contexts') %>%
filter(genotype == 'a5-i-KO')
# make sure you compare with saline baseline
PV_values$drug <- factor(PV_values$drug, levels = c("saline", "etomidate 2mg/kg", "etomidate 4mg/kg", "etomidate 6mg/kg", "etomidate 7mg/kg", "etomidate 8mg/kg"))
# test using LMEM & ANOVA
PV_values.model= lmer (PV_values ~ drug + (1|animal_ID) + (1|animal_ID:expt_date), data=PV_values, REML=FALSE)
anova(
PV_values.model,
type = c("III", "II", "I", "3", "2", "1"),
ddf = c("Satterthwaite", "Kenward-Roger", "lme4"))
# perform some plotting
par(mfrow=c(1,3))
PV_values.model= lmer (PV_values ~ drug + (1|animal_ID) + (1|animal_ID:expt_date), data=PV_values, REML=TRUE)
plot(residuals(PV_values.model),las=1, ylim=c(-2,2))
hist(residuals(PV_values.model),las=1)
qqnorm(residuals(PV_values.model),las=1)
qqline(residuals(PV_values.model), col = "red", lwd=2)
summary(PV_values.model)
sjPlot::plot_model(PV_values.model, title = "PV_values ~ drug + (1|animal_ID) + (1|animal_ID:expt_date)")
sjPlot:: tab_model(PV_values.model, title = "PV_values ~ drug + (1|animal_ID) + (1|animal_ID:expt_date)",
auto.label = TRUE, show.stat = TRUE, show.df = TRUE, show.se = TRUE)
# linear mixed model statistics for PV correlations
# load data
PV_correlation <- read_excel("D:/Meta_AnaOutput_Graphs/Zhu 2022 GAD paper (combined p-WTs)/PV_correlation.xlsx")
# filter out data based on mobility of the animal
PV_values <- PV_correlation %>%
filter(session1_mobility_pass == 1 & session2_mobility_pass == 1) %>%
filter(drug != 'altered contexts') %>%
filter(genotype == 'a5-pyr-KO')
# make sure you compare with saline baseline
PV_values$drug <- factor(PV_values$drug, levels = c("saline", "etomidate 2mg/kg", "etomidate 4mg/kg", "etomidate 6mg/kg", "etomidate 7mg/kg", "etomidate 8mg/kg"))
# test using LMEM & ANOVA
PV_values.model= lmer (PV_values ~ drug + (1|animal_ID) + (1|animal_ID:expt_date), data=PV_values, REML=FALSE)
anova(
PV_values.model,
type = c("III", "II", "I", "3", "2", "1"),
ddf = c("Satterthwaite", "Kenward-Roger", "lme4"))
# perform some plotting
par(mfrow=c(1,3))
PV_values.model= lmer (PV_values ~ drug + (1|animal_ID) + (1|animal_ID:expt_date), data=PV_values, REML=TRUE)
plot(residuals(PV_values.model),las=1, ylim=c(-2,2))
hist(residuals(PV_values.model),las=1)
qqnorm(residuals(PV_values.model),las=1)
qqline(residuals(PV_values.model), col = "red", lwd=2)
summary(PV_values.model)
sjPlot::plot_model(PV_values.model, title = "PV_values ~ drug + (1|animal_ID) + (1|animal_ID:expt_date)")
sjPlot:: tab_model(PV_values.model, title = "PV_values ~ drug + (1|animal_ID) + (1|animal_ID:expt_date)",
auto.label = TRUE, show.stat = TRUE, show.df = TRUE, show.se = TRUE)
# linear mixed model statistics for PV correlations
# load data
PV_correlation <- read_excel("D:/Meta_AnaOutput_Graphs/Zhu 2022 GAD paper (combined p-WTs)/PV_correlation.xlsx")
# filter out data based on mobility of the animal
PV_values <- PV_correlation %>%
filter(session1_mobility_pass == 1 & session2_mobility_pass == 1) %>%
filter(drug != 'altered contexts') %>%
filter(genotype == 'p-WT')
# make sure you compare with saline baseline
PV_values$drug <- factor(PV_values$drug, levels = c("saline", "etomidate 2mg/kg", "etomidate 4mg/kg", "etomidate 6mg/kg", "etomidate 7mg/kg", "etomidate 8mg/kg"))
# test using LMEM & ANOVA
PV_values.model= lmer (PV_values ~ drug + (1|animal_ID) + (1|animal_ID:expt_date), data=PV_values, REML=FALSE)
anova(
PV_values.model,
type = c("III", "II", "I", "3", "2", "1"),
ddf = c("Satterthwaite", "Kenward-Roger", "lme4"))
# perform some plotting
par(mfrow=c(1,3))
PV_values.model= lmer (PV_values ~ drug + (1|animal_ID) + (1|animal_ID:expt_date), data=PV_values, REML=TRUE)
plot(residuals(PV_values.model),las=1, ylim=c(-2,2))
hist(residuals(PV_values.model),las=1)
qqnorm(residuals(PV_values.model),las=1)
qqline(residuals(PV_values.model), col = "red", lwd=2)
summary(PV_values.model)
sjPlot::plot_model(PV_values.model, title = "PV_values ~ drug + (1|animal_ID) + (1|animal_ID:expt_date)")
sjPlot:: tab_model(PV_values.model, title = "PV_values ~ drug + (1|animal_ID) + (1|animal_ID:expt_date)",
auto.label = TRUE, show.stat = TRUE, show.df = TRUE, show.se = TRUE)
# linear mixed model statistics for RM correlations
# load data
RM_correlation <- read_excel("D:/Meta_AnaOutput_Graphs/Zhu 2022 GAD paper (combined p-WTs)/RM_correlation.xlsx")
# filter out data based on mobility of the animal
RM_values <- RM_correlation %>%
filter(session1_mobility_pass == 1 & session2_mobility_pass == 1) %>%
filter(drug != 'altered contexts') %>%
filter(genotype == 'p-WT')
# make sure you compare with saline baseline
RM_values$drug <- factor(RM_values$drug, levels = c("saline", "etomidate 2mg/kg", "etomidate 4mg/kg", "etomidate 6mg/kg", "etomidate 7mg/kg", "etomidate 8mg/kg"))
# test using LMEM & ANOVA
RM_values.model= lmer (RM_values ~ drug + (1|animal_ID) + (1|animal_ID:expt_date), data=RM_values, REML=FALSE)
anova(
RM_values.model,
type = c("III", "II", "I", "3", "2", "1"),
ddf = c("Satterthwaite", "Kenward-Roger", "lme4"))
# perform some plotting
par(mfrow=c(1,3))
RM_values.model= lmer (RM_values ~ drug + (1|animal_ID) + (1|animal_ID:expt_date), data=RM_values, REML=TRUE)
plot(residuals(RM_values.model),las=1, ylim=c(-2,2))
hist(residuals(RM_values.model),las=1)
qqnorm(residuals(RM_values.model),las=1)
qqline(residuals(RM_values.model), col = "red", lwd=2)
summary(RM_values.model)
sjPlot::plot_model(RM_values.model, title = "RM_values ~ drug + (1|animal_ID) + (1|animal_ID:expt_date)")
sjPlot:: tab_model(RM_values.model, title = "RM_values ~ drug + (1|animal_ID) + (1|animal_ID:expt_date)",
auto.label = TRUE, show.stat = TRUE, show.df = TRUE, show.se = TRUE)
# linear mixed model statistics for RM correlations
# load data
RM_correlation <- read_excel("D:/Meta_AnaOutput_Graphs/Zhu 2022 GAD paper (combined p-WTs)/RM_correlation.xlsx")
# filter out data based on mobility of the animal
RM_values <- RM_correlation %>%
filter(session1_mobility_pass == 1 & session2_mobility_pass == 1) %>%
filter(drug != 'altered contexts') %>%
filter(genotype == 'a5-i-KO')
# make sure you compare with saline baseline
RM_values$drug <- factor(RM_values$drug, levels = c("saline", "etomidate 2mg/kg", "etomidate 4mg/kg", "etomidate 6mg/kg", "etomidate 7mg/kg", "etomidate 8mg/kg"))
# test using LMEM & ANOVA
RM_values.model= lmer (RM_values ~ drug + (1|animal_ID) + (1|animal_ID:expt_date), data=RM_values, REML=FALSE)
anova(
RM_values.model,
type = c("III", "II", "I", "3", "2", "1"),
ddf = c("Satterthwaite", "Kenward-Roger", "lme4"))
# perform some plotting
par(mfrow=c(1,3))
RM_values.model= lmer (RM_values ~ drug + (1|animal_ID) + (1|animal_ID:expt_date), data=RM_values, REML=TRUE)
plot(residuals(RM_values.model),las=1, ylim=c(-2,2))
hist(residuals(RM_values.model),las=1)
qqnorm(residuals(RM_values.model),las=1)
qqline(residuals(RM_values.model), col = "red", lwd=2)
summary(RM_values.model)
sjPlot::plot_model(RM_values.model, title = "RM_values ~ drug + (1|animal_ID) + (1|animal_ID:expt_date)")
sjPlot:: tab_model(RM_values.model, title = "RM_values ~ drug + (1|animal_ID) + (1|animal_ID:expt_date)",
auto.label = TRUE, show.stat = TRUE, show.df = TRUE, show.se = TRUE)
# linear mixed model statistics for RM correlations
# load data
RM_correlation <- read_excel("D:/Meta_AnaOutput_Graphs/Zhu 2022 GAD paper (combined p-WTs)/RM_correlation.xlsx")
# filter out data based on mobility of the animal
RM_values <- RM_correlation %>%
filter(session1_mobility_pass == 1 & session2_mobility_pass == 1) %>%
filter(drug != 'altered contexts') %>%
filter(genotype == 'a5-pyr-KO')
# make sure you compare with saline baseline
RM_values$drug <- factor(RM_values$drug, levels = c("saline", "etomidate 2mg/kg", "etomidate 4mg/kg", "etomidate 6mg/kg", "etomidate 7mg/kg", "etomidate 8mg/kg"))
# test using LMEM & ANOVA
RM_values.model= lmer (RM_values ~ drug + (1|animal_ID) + (1|animal_ID:expt_date), data=RM_values, REML=FALSE)
anova(
RM_values.model,
type = c("III", "II", "I", "3", "2", "1"),
ddf = c("Satterthwaite", "Kenward-Roger", "lme4"))
# perform some plotting
par(mfrow=c(1,3))
RM_values.model= lmer (RM_values ~ drug + (1|animal_ID) + (1|animal_ID:expt_date), data=RM_values, REML=TRUE)
plot(residuals(RM_values.model),las=1, ylim=c(-2,2))
hist(residuals(RM_values.model),las=1)
qqnorm(residuals(RM_values.model),las=1)
qqline(residuals(RM_values.model), col = "red", lwd=2)
summary(RM_values.model)
sjPlot::plot_model(RM_values.model, title = "RM_values ~ drug + (1|animal_ID) + (1|animal_ID:expt_date)")
sjPlot:: tab_model(RM_values.model, title = "RM_values ~ drug + (1|animal_ID) + (1|animal_ID:expt_date)",
auto.label = TRUE, show.stat = TRUE, show.df = TRUE, show.se = TRUE)
# initialization of libraries for general use
# be sure that the following packages are installed
#   dplyr
#   ggplot2
#   lme4
#   Matrix and matrixStats
#   readxl
#   tidyr and tidyverse
#   fitdistrplus
#   sjPlot
#   ggpubr
#   lmerTest
library(matrixStats)
library(lme4)
library(tidyverse)
library(readxl)
library(ggplot2)
library(fitdistrplus)
library(sjPlot)  #for plotting lmer and glmer mods
library(ggpubr)
library(lmerTest)
# linear mixed model statistics Mobility
# load data
Mobility <- read_excel("D:/Meta_AnaOutput_Graphs/Zhu 2022 GAD paper (combined p-WTs)/Mobility.xlsx")
# filter out some data that shouldn't be included
Mobility_values <- Mobility %>%
filter(drug != 'altered contexts')
# compare with p-WT (baseline)
Mobility_values$genotype <- factor(Mobility_values$genotype, levels = c("p-WT", "a5-i-KO", 'a5-pyr-KO'))
# make sure you compare with saline baseline
Mobility_values$drug <- factor(Mobility_values$drug, levels = c("saline", "etomidate 2mg/kg", "etomidate 4mg/kg", "etomidate 6mg/kg", "etomidate 7mg/kg", "etomidate 8mg/kg"))
# test using LMEM & ANOVA
Mobility_values.model= lmer (Session1_Mobility ~ drug * genotype + (1|animal_ID) + (1|expt_date), data=Mobility_values, REML=TRUE)
anova(
Mobility_values.model,
type = c("III", "II", "I", "3", "2", "1"),
ddf = "Kenward-Roger")
# perform some plotting
par(mfrow=c(1,3))
Mobility_values.model= lmer (Session1_Mobility ~ drug * genotype + (1|animal_ID) + (1|expt_date), data=Mobility_values, REML=TRUE)
plot(residuals(Mobility_values.model),las=1, ylim=c(-1,1))
hist(residuals(Mobility_values.model),las=1)
qqnorm(residuals(Mobility_values.model),las=1)
qqline(residuals(Mobility_values.model), col = "red", lwd=2)
summary(Mobility_values.model)
sjPlot::plot_model(Mobility_values.model, title = "Mobility_values ~ drug * genotype + (1|animal_ID) + (1|expt_date)")
sjPlot:: tab_model(Mobility_values.model, title = "Mobility_values ~ drug * genotype + (1|animal_ID) + (1|expt_date)",
auto.label = TRUE, show.stat = TRUE, show.df = TRUE, show.se = TRUE)
# Perform LMEM statistics on pMI and MI data (place cell proportions)
# specify directory to the data file (excel/csv)
# change to match your local machine
MI_and_pMI <- read_excel("D:/Meta_AnaOutput_Graphs/Zhu 2022 GAD paper (combined p-WTs)/MI_and_pMI.xlsx")
# get data and filter for only first session (day1/AM)
# filter out data where mobility is below a certain threshold
MIfreq <- MI_and_pMI
MI_data_AM_day1_only <- MIfreq %>%
filter(expt_time == "day1" | expt_time == "AM") %>%
filter(Mobility_Pass == 1) %>%
filter(drug != 'altered contexts')
# filter out data that you don't need for place cell statistics
MIfreq <- MI_data_AM_day1_only %>%
nest_by(session,genotype,animal_ID,drug,expt_date,.keep=TRUE) %>%
filter(drug != "altered contexts") %>%
dplyr::select(session,genotype,animal_ID,drug,expt_date)
# compare with p-WT (baseline)
MIfreq$genotype <- factor(MIfreq$genotype, levels = c("p-WT", "a5-i-KO", 'a5-pyr-KO'))
# adjust the levels of data & set the baseline (saline) for comparison
MIfreq$drug <- factor(MIfreq$drug, levels = c("saline", "etomidate 2mg/kg", "etomidate 4mg/kg", "etomidate 6mg/kg", "etomidate 7mg/kg", "etomidate 8mg/kg"))
# avoid bugs
MIfreq <- MIfreq %>%
group_by(genotype) %>%
add_column(lowMIfreq = 0) # add empty column to fill in later with frequencies
# p-value is set as variable lowMI
lowMI = 0.05
numRowsTable = NROW(MIfreq)
for (i in 1:numRowsTable){
df <- MI_data_AM_day1_only %>%
filter(session == as.character(MIfreq[i,1]))
freq = NROW(filter(df, MI_p_values<lowMI)) / NROW(df)
MIfreq[i,6]=freq
}
# make table of average values of pMI by animal_ID under each condition
pMItable <- aggregate(lowMIfreq ~ genotype:animal_ID:drug, data = MIfreq, mean,
simplify = TRUE)
#################################################################
# test for interaction in mixed effects model
MI.model= lmer (lowMIfreq ~ drug * genotype + (1|animal_ID) + (1|expt_date), data=MIfreq, REML=FALSE)
anova(
MI.model,
type = c("III", "II", "I", "3", "2", "1"),
ddf = c("Satterthwaite", "Kenward-Roger", "lme4"))
# generate figs
MI.model= lmer(lowMIfreq ~ drug * genotype + (1|animal_ID) + (1|expt_date), data=MIfreq, REML=TRUE)
par(mfrow=c(1,3))
plot(residuals(MI.model),las=1, ylim=c(-2,2))
hist(residuals(MI.model),las=1)
qqnorm(residuals(MI.model),las=1)
qqline(residuals(MI.model), col = "red", lwd=2)
coef(MI.model)
summary(MI.model)
sjPlot::plot_model(MI.model, title = "MI ~ drug * genotype  + (1|animal_ID) + (1|expt_date)")
sjPlot:: tab_model(MI.model, title = "MI ~  (1|animal_ID) + (1|expt_date)")
# linear mixed model statistics for RM correlations
# load data
RM_correlation <- read_excel("D:/Meta_AnaOutput_Graphs/Zhu 2022 GAD paper (combined p-WTs)/RM_correlation.xlsx")
# filter out data based on animal's mobility
RMvalues <- RM_correlation %>%
filter(session1_mobility_pass == 1 & session2_mobility_pass == 1) %>%
filter(drug != 'altered contexts')
# compare with p-WT (baseline)
RMvalues$genotype <- factor(RMvalues$genotype, levels = c("p-WT", "a5-i-KO", 'a5-pyr-KO'))
# make sure you compare with saline baseline
RMvalues$drug <- factor(RMvalues$drug, levels = c("saline", "etomidate 2mg/kg", "etomidate 4mg/kg", "etomidate 6mg/kg", "etomidate 7mg/kg", "etomidate 8mg/kg"))
# test using LMEM & ANOVA
RM_values.model= lmer (RM_values ~ drug * genotype + (1|animal_ID) + (1|animal_ID:expt_date) + (1|cell_ID:animal_ID), data=RMvalues, REML=FALSE)
anova(
RM_values.model,
type = c("III", "II", "I", "3", "2", "1"),
ddf = c("Satterthwaite", "Kenward-Roger", "lme4"))
# perform some plotting
par(mfrow=c(1,3))
RM_values.model= lmer (RM_values ~ drug * genotype + (1|animal_ID) + (1|animal_ID:expt_date) + (1|cell_ID:animal_ID), data=RMvalues, REML=TRUE)
plot(residuals(RM_values.model),las=1, ylim=c(-2,2))
hist(residuals(RM_values.model),las=1)
qqnorm(residuals(RM_values.model),las=1)
qqline(residuals(RM_values.model), col = "red", lwd=2)
summary(RM_values.model)
sjPlot::plot_model(RM_values.model, title = "RM_values ~ drug * genotype + (1|animal_ID) + (1|animal_ID:expt_date) + (1|cell:animal_ID)")
sjPlot:: tab_model(RM_values.model, title = "RM_values ~ drug * genotype + (1|animal_ID) + (1|animal_ID:expt_date) + (1|cell:animal_ID)",
auto.label = TRUE, show.stat = TRUE, show.df = TRUE, show.se = TRUE)
# linear mixed model statistics for RM correlations
# load data
RM_correlation <- read_excel("D:/Meta_AnaOutput_Graphs/Zhu 2022 GAD paper (combined p-WTs)/RM_correlation.xlsx")
# filter out data based on mobility of the animal
RM_values <- RM_correlation %>%
filter(session1_mobility_pass == 1 & session2_mobility_pass == 1) %>%
filter(drug == 'saline' | drug == 'altered contexts')
# compare with p-WT (baseline)
RM_values$genotype <- factor(RM_values$genotype, levels = c("p-WT", "a5-i-KO", 'a5-pyr-KO'))
# make sure you compare with saline baseline
RM_values$drug <- factor(RM_values$drug, levels = c("saline", "altered contexts"))
# test using LMEM & ANOVA
RM_values.model= lmer (RM_values ~ drug * genotype + (1|animal_ID) + (1|animal_ID:expt_date), data=RM_values, REML=FALSE)
anova(
RM_values.model,
type = c("III", "II", "I", "3", "2", "1"),
ddf = c("Satterthwaite", "Kenward-Roger", "lme4"))
# perform some plotting
par(mfrow=c(1,3))
RM_values.model= lmer (RM_values ~ drug * genotype + (1|animal_ID) + (1|animal_ID:expt_date), data=RM_values, REML=TRUE)
plot(residuals(RM_values.model),las=1, ylim=c(-2,2))
hist(residuals(RM_values.model),las=1)
qqnorm(residuals(RM_values.model),las=1)
qqline(residuals(RM_values.model), col = "red", lwd=2)
summary(RM_values.model)
sjPlot::plot_model(RM_values.model, title = "RM_values ~ drug * genotype + (1|animal_ID) + (1|animal_ID:expt_date)")
sjPlot:: tab_model(RM_values.model, title = "RM_values ~ drug * genotype + (1|animal_ID) + (1|animal_ID:expt_date)",
auto.label = TRUE, show.stat = TRUE, show.df = TRUE, show.se = TRUE)
# linear mixed model statistics for PV correlations
# load data
PV_correlation <- read_excel("D:/Meta_AnaOutput_Graphs/Zhu 2022 GAD paper (combined p-WTs)/PV_correlation.xlsx")
# filter out data based on mobility of the animal
PV_values <- PV_correlation %>%
filter(session1_mobility_pass == 1 & session2_mobility_pass == 1) %>%
filter(drug != 'altered contexts')
# compare with p-WT (baseline)
PV_values$genotype <- factor(PV_values$genotype, levels = c("p-WT", "a5-i-KO", 'a5-pyr-KO'))
# make sure you compare with saline baseline
PV_values$drug <- factor(PV_values$drug, levels = c("saline", "etomidate 2mg/kg", "etomidate 4mg/kg", "etomidate 6mg/kg", "etomidate 7mg/kg", "etomidate 8mg/kg"))
# test using LMEM & ANOVA
PV_values.model= lmer (PV_values ~ drug * genotype + (1|animal_ID) + (1|animal_ID:expt_date), data=PV_values, REML=FALSE)
anova(
PV_values.model,
type = c("III", "II", "I", "3", "2", "1"),
ddf = c("Satterthwaite", "Kenward-Roger", "lme4"))
# perform some plotting
par(mfrow=c(1,3))
PV_values.model= lmer (PV_values ~ drug * genotype + (1|animal_ID) + (1|animal_ID:expt_date), data=PV_values, REML=TRUE)
plot(residuals(PV_values.model),las=1, ylim=c(-2,2))
hist(residuals(PV_values.model),las=1)
qqnorm(residuals(PV_values.model),las=1)
qqline(residuals(PV_values.model), col = "red", lwd=2)
summary(PV_values.model)
sjPlot::plot_model(PV_values.model, title = "PV_values ~ drug * genotype + (1|animal_ID) + (1|animal_ID:expt_date)")
sjPlot:: tab_model(PV_values.model, title = "PV_values ~ drug * genotype + (1|animal_ID) + (1|animal_ID:expt_date)",
auto.label = TRUE, show.stat = TRUE, show.df = TRUE, show.se = TRUE)
# linear mixed model statistics ERcorr
# load data
ERcorr <- read_excel("D:/Meta_AnaOutput_Graphs/Zhu 2022 GAD paper (combined p-WTs)/ER_correlation.xlsx")
# filter out some data that shouldn't be included
ERcorr_values <- ERcorr %>%
filter(drug != 'altered contexts') %>%
filter(session1_mobility_pass == 1)
# compare with p-WT (baseline)
ERcorr_values$genotype <- factor(ERcorr_values$genotype, levels = c("p-WT", "a5-i-KO", 'a5-pyr-KO'))
# make sure you compare with saline baseline
ERcorr_values$drug <- factor(ERcorr_values$drug, levels = c("saline", "etomidate 2mg/kg", "etomidate 4mg/kg", "etomidate 6mg/kg", "etomidate 7mg/kg", "etomidate 8mg/kg"))
# test using LMEM & ANOVA
ERcorr_values.model= lmer (Event_Rate_Correlation ~ drug * genotype + (1|animal_ID) + (1|expt_date), data=ERcorr_values, REML=TRUE)
anova(
ERcorr_values.model,
type = c("III", "II", "I", "3", "2", "1"),
ddf = "Kenward-Roger")
# perform some plotting
par(mfrow=c(1,3))
ERcorr_values.model= lmer (Event_Rate_Correlation ~ drug * genotype + (1|animal_ID) + (1|expt_date), data=ERcorr_values, REML=TRUE)
plot(residuals(ERcorr_values.model),las=1, ylim=c(-1,1))
hist(residuals(ERcorr_values.model),las=1)
qqnorm(residuals(ERcorr_values.model),las=1)
qqline(residuals(ERcorr_values.model), col = "red", lwd=2)
summary(ERcorr_values.model)
sjPlot::plot_model(ERcorr_values.model, title = "ERcorr_values ~ drug * genotype + (1|animal_ID) + (1|expt_date)")
sjPlot:: tab_model(ERcorr_values.model, title = "ERcorr_values ~ drug * genotype + (1|animal_ID) + (1|expt_date)",
auto.label = TRUE, show.stat = TRUE, show.df = TRUE, show.se = TRUE)
